﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using PS.Practices.Provisioner.Provisioner.Schema.Logic;

namespace PS.Practices.Provisioner.Test.Integration.ServiceLocator
{
    class ListOpServiceLocator
    {

        private IDictionary<object, object> services;

        internal ListOpServiceLocator(SPList list, SPWeb web, Dictionary<string, object> properties )
        {
            services = new Dictionary<object, object>();

            this.services.Add(typeof(IListOperationVisitor), new OmListOperationVisitor(list, web, properties));
        }

        public T GetService<T>()
        {
            try
            {
                return (T) services[typeof (T)];
            }
            catch (KeyNotFoundException)
            {
                
                throw new ApplicationException("The requested services is not registered");
            }
        }
    }
}
